package com.onlineMIS.ORM.DAO.chainS.user;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.onlineMIS.ORM.DAO.BaseDAO;
import com.onlineMIS.ORM.entity.chainS.user.ChainRoleType;
import com.onlineMIS.ORM.entity.chainS.user.ChainStore;

@Repository
public class ChainRoleTypeDaoImpl extends BaseDAO<ChainRoleType> {

	public void initialize(ChainRoleType chainRoleType){
		this.getHibernateTemplate().initialize(chainRoleType.getChainUserFunctionalities());
	}
	
   /**
    * 获取当前所有 能用的连锁店权限
    * @return
    */
   public List<ChainRoleType> getAllChainUserTypes(){
	   DetachedCriteria criteria = DetachedCriteria.forClass(ChainRoleType.class);
	   criteria.add(Restrictions.eq("isHead", ChainRoleType.IS_CHAIN));
	   criteria.add(Restrictions.eq("status", ChainRoleType.STATUS_OK));	// 正常状态角色
	   criteria.addOrder(Order.asc("chainRoleTypeId"));
	   return this.getByCritera(criteria, true);
   }
   



	public List<ChainRoleType> getHqRoles() {
		DetachedCriteria criteria = DetachedCriteria.forClass(ChainRoleType.class);
		criteria.add(Restrictions.eq("isHead", ChainRoleType.IS_HEAD));
		criteria.add(Restrictions.eq("status", ChainRoleType.STATUS_OK));	// 正常状态角色
		criteria.addOrder(Order.asc("chainRoleTypeId"));
		
		return this.getByCritera(criteria, true);
	}





}
